package com.qf.fanwang.controller;

import com.alibaba.fastjson.JSON;
import com.qf.fanwang.pojo.Good;
import com.qf.fanwang.service.GoodService;
import com.qf.fanwang.service.impl.GoodServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
@WebServlet("/good")

public class GoodController extends BaseController {
    private GoodService goodService=new GoodServiceImpl();
   //@RequestMapping(value = "selectItme",produces = "application/json;charset=UTF-8")
    public String selectItme(HttpServletRequest req, HttpServletResponse resp) {
        //根据一级分类的id查询对应的所有二级分类
        List<Good> list=new ArrayList<Good>();
        String ids=req.getParameter("id");
        int id=-1;
        if(ids!=null) {
            id=Integer.valueOf(ids);
            list=goodService.selectALLById(id);
        }




        return JSON.toJSONString(list);//将对象转换为JSON串

    }
}
